Skip to content

Expose ImportAdder to IPC API - #3881

Merged
andrewbranch merged 7 commits into
microsoft:mainfrom
andrewbranch:api-import-adder
Jul 13, 2026
Merged

Expose ImportAdder to IPC API#3881
andrewbranch merged 7 commits into
microsoft:mainfrom
andrewbranch:api-import-adder

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

No description provided.

@navya9singh
navya9singh marked this pull request as ready for review June 30, 2026 19:45
Copilot AI review requested due to automatic review settings June 30, 2026 19:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the native-preview IPC API to expose ImportAdder-based auto-import edit computation to clients, including logic to ensure the auto-import registry is prepared for the target file and tests validating the new behavior.

Changes:

  • Added a new IPC method getImportAdderEdits (Go server) that computes/coalesces import edits via autoimport.ImportAdder, preparing auto-import data on-demand.
  • Added Session.GetSnapshotWithAutoImports (Go project session) to clone/adopt an auto-import-prepared snapshot without flushing pending file changes, plus a regression test for snapshot adoption.
  • Added native-preview async/sync client APIs + types and tests to request and apply returned TextEdit[] results.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/project/snapshot_test.go Adds a snapshot regression test asserting auto-import-prepared snapshots are adopted when unchanged.
internal/project/session.go Introduces GetSnapshotWithAutoImports and refactors auto-import snapshot cloning/adoption.
internal/api/session.go Adds handleGetImportAdderEdits server handler to compute ImportAdder edits from symbol actions.
internal/api/proto.go Adds protocol method/params for getImportAdderEdits and a TextEdit payload type.
_packages/native-preview/test/sync/api.test.ts Adds sync client tests for import edit computation and action validation.
_packages/native-preview/test/async/api.test.ts Adds async client tests for import edit computation and action validation.
_packages/native-preview/src/api/sync/types.ts Adds ImportAdderAction / options types in the sync surface area.
_packages/native-preview/src/api/sync/api.ts Adds sync Project.getImportAdderEdits and convenience wrapper.
_packages/native-preview/src/api/proto.ts Adds TextEdit + ImportAdderActionRequest protocol request types.
_packages/native-preview/src/api/async/types.ts Adds ImportAdderAction / options types in the async surface area.
_packages/native-preview/src/api/async/api.ts Adds async Project.getImportAdderEdits and convenience wrapper.

Comment thread _packages/native-preview/src/api/proto.ts
Comment thread _packages/native-preview/src/api/async/api.ts
@andrewbranch andrewbranch added this to the Post-7.0 milestone Jun 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment on lines +1163 to 1165
if callerRef {
newSnapshot.ref()
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok because it's a fresh clone that nobody else could have gotten access to yet.

Comment thread internal/api/session.go Outdated
Comment thread internal/api/session.go Outdated
Comment thread _packages/native-preview/src/api/async/types.ts
@andrewbranch
andrewbranch requested a review from gabritto July 10, 2026 23:00
@andrewbranch
andrewbranch added this pull request to the merge queue Jul 13, 2026
Merged via the queue into microsoft:main with commit 8a74937 Jul 13, 2026
21 checks passed
@andrewbranch
andrewbranch deleted the api-import-adder branch July 13, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants